<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
</head>
<body>
    <h3>原型和隐式原型</h3>

    <script>
        // 原型：prototype ,是构造函数的属性    
        // 隐式原型：__proto__ ,是实例对象的属性  

        // 构造函数： Array      People
        // 实例对象： var arr = new Array()   var xiaoming = new People()

        // 示例：
        function People(){}
        var xiaoming = new People();
        console.log(People.prototype);// 原型
        console.log(xiaoming.__proto__);//隐式原型

        // 在隐式原型上添加的方法
        xiaoming.__proto__.sayHello = function(){
            console.log("hello world!");
        }

        People.prototype.sayHello2 = function(){// 常用编码方式
            console.log("hello world!222");
        }

        console.log(People.prototype === xiaoming.__proto__ );// true

        xiaoming.sayHello();// hello world!
        xiaoming.sayHello2();// hello world!222




    </script>
</body>
</html>